'use strict';

var router = require('./router');
var logger = require('koa-logger');
var render = require('koa-swig');
var path = require('path');
var serve = require('koa-static');
var session = require('koa-session');
var flash = require('koa-flash');
var koala = require('koala');
var config = require('./config');
var app = koala();

app.context.render = render({
  root: path.join(__dirname, 'views'),
  autoescape: true,
  cache: false, // disable, set to false 
  ext: 'html'
});

app.use(serve(__dirname + '/static'));

app.keys = ['qeeniao'];
app.use(session({},app));
app.use(flash());

app.use(logger());
app.use(router.routes());

app.listen(config.port);

console.log('Server start on Listening '+config.port);